USE [i8office]
GO

if (exists(select * from sys.objects where name='proc_wkf_nodepath'))
	drop proc proc_wkf_nodepath
go
create proc proc_wkf_nodepath(
	@MessageID nvarchar(36),
	@TemplateMessageID nvarchar(36)
)
	as
	INSERT INTO [dbo].[WKF_NodePath]
			   ([MessageID]
			   ,[NodeKey]
			   ,[TargetNodeKey]
			   ,[NodePathName]
			   ,[NodePathType]
			   ,[NodePathStatus]
			   ,[NodePathFinishTime]
			   ,[NodePathTarget]
			   ,[NodePathCondition]
			   ,[SortNo])
		SELECT @MessageID
			  ,[NodeKey]
			  ,[TargetNodeKey]
			  ,[NodePathName]
			  ,[NodePathType]
			  ,[NodePathStatus]
			  ,[NodePathFinishTime]
			  ,[NodePathTarget]
			  ,[NodePathCondition]
			  ,[SortNo]
		  FROM [dbo].[WKF_NodePath]
		  WHERE MessageID=@TemplateMessageID
	UPDATE [dbo].[WKF_NodePath] SET NodePathStatus=1, NodePathFinishTime=GETDATE() WHERE MessageID=@MessageID AND NodeKey='NODE0001';



